package com.example.waibao.entity;

import com.fasterxml.jackson.annotation.JsonInclude;


//用于指定在序列化和反序列化过程中，对于值为null的属性或字段，是否应该忽略它们。如果使用该注解，那么在序列化时，值为null的属性或字段将不会
//被写入JSON数据中；在反序列化时，值为null的属性或字段将不会被赋值。这可以减少JSON数据的大小和传输时间，以及避免在值为null的情况下引发空指针异常。
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public ResponseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public ResponseResult(Integer code, T data) {
        this.code = code;
        this.data = data;
    }
    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
